package com.bosch.in.rtp1.ept.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Utility class is used to eagerly loading all predefined sql statements in property file then 
 * make it available for DAO classes. 
 * @author TPR1HC
 *
 */
public class SQLStatementLoader {
	/**
	 * Constant string for query lotstatus 
	 */
	private static final String LOTSTATUS_QUERY;
	
	/**
	 * Constant string for query hold code filter
	 */
	private static final String HCFILTER_QUERY;
	
	/**
	 * Constant string for query all hold code filter
	 */
	private static final String HC_ALL_FILTER_QUERY;
	
	/**
	 * Constant string for update hold code filter
	 */
	private static final String HCFILTER_UPDATE;
	
	/**
	 * Constant string for insert hold code filter
	 */
	private static final String HCFILTER_INSERT;
	
	/**
	 * Constant string for delete hold code filter
	 */
	private static final String HCFILTER_DELETE;
	
	/**
	 * Constant string for query last order of holdcode filter 
	 */
	private static final String HCFILTER_LAST_ORDER;
	
	/**
	 * Constant string for reorder holdcode filter
	 */
	private static final String HCFILTER_REORDER;
	
	/**
	 * Constant string for moving REST to last row
	 */
	private static final String HCFILTER_SET_LAST_POS;
	
	/**
	 * Constant string for query fxFactor 
	 */
	private static final String FX_FACTOR_SELECT;
	
	/**
	 * Constant string for update fxFactor
	 */
	private static final String FX_FACTOR_UPDATE;
	
	/**
	 * Constant string for insert fxFactor
	 */
	private static final String FX_FACTOR_INSERT;
	
	/**
	 * Constant string for location list
	 */
	private static final String FSH_RCP_LOCATION_LIST;
	
	/**
	 * Constant string for finished recipe list
	 */	
	private static final String FSH_RCP_STAGE_LIST;
	
	/**
	 * Constant string for load skipped finished recipe condition
	 */	
	private static final String SKP_FSH_RCP_CON_SEL;
	
	/**
	 * Constant string for update skipped finished recipe condition
	 */	
	private static final String SKP_FSH_RCP_CON_UPD;
	
	/**
	 * Constant string for update all skipped value of finished recipes
	 */	
	private static final String FSH_RCP_UPD_SKIPPED;
	
	/**
	 * Constant string for insert skipped finished recipe condition
	 */	
	private static final String SKP_FSH_RCP_CON_INS;
	
	/**
	 * Constant string for stage list
	 */	
	private static final String FSH_RCP_EQPTYPE_LIST;
	
	/**
	 * Constant string for selecting released holds
	 */
	private static final String RELEASED_HOLDS_SELECT;
	
	/**
	 * Constant string for updating released holds
	 */
	private static final String RELEASED_HOLDS_UPDATE;
	
	/**
	 * resource file which contains all necessary sql statement
	 */
	private static final String PROP_FILE = "/sqlStatement.properties";
	
	/**
	 * Constant string for selecting chart factors 
	 */
	
	private static final String FSH_RCP_FACTOR_4_CHART;
	
	/**
	 * Constant string for selecting released hold chart factors 
	 */
	
	private static final String REL_HLD_FACTOR_4_CHART;
	
	/**
	 * Constant string for selecting active hold chart factors 
	 */
	
	private static final String ACT_HLD_FACTOR_4_CHART;
	
	/**
	 * Constant string for selecting hold duration chart factors 
	 */
	
	private static final String HLD_DUR_BY_MONTH_CHART;
	
	/**
	 * Constant string for selecting all table column
	 */
	private static final String FRZ_COL_SELECT_ALL;
	
	/**
	 * Constant string for clearing all scroll column
	 */
	private static final String FRZ_COL_CLEAR;
	
	/**
	 * Constant string for updating scroll column
	 */
	private static final String FRZ_COL_UPDATE;
	
	/**
	 * Constant string for selecting duration color setting
	 */
	private static final String DUR_COL_SEL;
	
	/**
	 * Constant string for updating duration color
	 */
	private static final String DUR_COL_UPDATE;
	
	/**
	 * Constant string for loading FshRcpRecord
	 */
	private static final String FSH_RCP_RECORDS;
	
	/**
	 * Constant string for counting total FshRcp Record
	 */
	private static final String FSH_RCP_TOTAL_REC;
	
	/**
	 * Constant string for selecting password
	 */
	private static final String PWD_SELECT;
	
	/**
	 * Constant string for selecting links
	 */
	private static final String LINKS_SELECT;
	/**
	 * Constant string for updating link
	 */
	private static final String LINKS_UPDATE;
	/**
	 * Constant string for inserting link
	 */
	private static final String LINKS_INSERT;
	/**
	 * Constant string for deleting link
	 */
	private static final String LINKS_DELETE;
	
	// eagerly loading predefined sql statements.
	static {
		Properties props = new Properties();
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
	    InputStream is = classLoader.getResourceAsStream(PROP_FILE);
	    try {
			props.load(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
		// get lot status query statement
		LOTSTATUS_QUERY = props.getProperty("lotstatus.select");
		
		// get hold code filter query statement
		HCFILTER_QUERY = props.getProperty("hcfilter.select");
		
		// get all hold cold filter query statement
		HC_ALL_FILTER_QUERY = props.getProperty("hcfilter.selectAll");
		
		// get hold code filter insert statement
		HCFILTER_INSERT = props.getProperty("hcfilter.insert");
		
		// get hold code filter update statement
		HCFILTER_UPDATE = props.getProperty("hcfilter.update");
		
		// get hold code filter delete statement
		HCFILTER_DELETE = props.getProperty("hcfilter.delete");
		
		// get last order of holdcode filter
		HCFILTER_LAST_ORDER = props.getProperty("hcfilter.lastorder");
		
		// get holdcode filter reorder statement
		HCFILTER_REORDER = props.getProperty("hcfilter.reorder");
		
		// get holdcode filter update REST position to last position
		HCFILTER_SET_LAST_POS = props.getProperty("hcfilter.setLastPos");
		
		// get fx factor query statement
		FX_FACTOR_SELECT = props.getProperty("fxFactor.select");
		
		// get fx factor insert statement
		FX_FACTOR_INSERT = props.getProperty("fxFactor.insert");
		
		// get fx factor update statement
		FX_FACTOR_UPDATE = props.getProperty("fxFactor.update");
		
		// get location list query statement
		FSH_RCP_LOCATION_LIST = props.getProperty("fshRecipe.locations");
		
		// get stage list query statement
		FSH_RCP_STAGE_LIST = props.getProperty("fshRecipe.stages");
		
		// get eqptype list query statement
		FSH_RCP_EQPTYPE_LIST = props.getProperty("fshRecipe.equptype");
		
		// get releasedHolds query statement
		RELEASED_HOLDS_SELECT = props.getProperty("releasedhold.select");
		
		// get releasedHolds update statement
		RELEASED_HOLDS_UPDATE = props.getProperty("releasedhold.update");
		
		// get chart factors
		FSH_RCP_FACTOR_4_CHART = props.getProperty("fshRecipe.selectChartRecord");
		
		// get load skipped finished recipe query statement 
		SKP_FSH_RCP_CON_SEL = props.getProperty("skpFshRcp.select");
		
		// get update skipped finished recipe query statement
		SKP_FSH_RCP_CON_UPD = props.getProperty("skpFshRcp.update");
		
		// get insert skipped finished recipe query statement
		SKP_FSH_RCP_CON_INS = props.getProperty("skpFshRcp.insert");
		
		// get update skipped column finished recipe statement
		FSH_RCP_UPD_SKIPPED = props.getProperty("skpFshRcp.updateAll");
		
		// get released hold chart factors
		REL_HLD_FACTOR_4_CHART = props.getProperty("relHld.selectChartRecord");

		// get released hold chart factors
		ACT_HLD_FACTOR_4_CHART = props.getProperty("activeHold.selectChartRecord");
		
		// get released hold duration by month factors
		HLD_DUR_BY_MONTH_CHART = props.getProperty("hldRel.hldDurByMonth");
		
		// get query statement to load all columns setting
		FRZ_COL_SELECT_ALL = props.getProperty("frozenCol.selectAll");
		
		// get query statement to clear setting of scrolling column
		FRZ_COL_CLEAR = props.getProperty("frozenCol.clearAll");
		
		// get query statement to update setting of scrolling column
		FRZ_COL_UPDATE = props.getProperty("frozenCol.update");
		
		// get query statement to select duration color setting
		DUR_COL_SEL = props.getProperty("durcol.select");
		
		// get query statement to update duration color setting
		DUR_COL_UPDATE = props.getProperty("durcol.update");
		
		// get query statement to selecting FshRcpRecords
		FSH_RCP_RECORDS = props.getProperty("fshRecipe.loadFactorDetail");
		
		// get query statement to count total FshRcpRecords
		FSH_RCP_TOTAL_REC = props.getProperty("fshRecipe.totalRecord");
		
		// get query statement to select password
		PWD_SELECT = props.getProperty("auth.select");
		
		// get query statement to select link list
		LINKS_SELECT = props.getProperty("linklist.select");
		
		// get query statement to select link list
		LINKS_UPDATE = props.getProperty("linklist.update");
		
		// get query statement to select link list
		LINKS_INSERT = props.getProperty("linklist.insert");
		
		// get query statement to select link list
		LINKS_DELETE = props.getProperty("linklist.delete");
	}
	
	/**
	 * Get query statement to get lotstatus list
	 * @return
	 */
	public static String getLotStatusQuery() {
		return LOTSTATUS_QUERY;
	}

	/**
	 * Get query statement to get hold code filter list
	 * @return
	 */
	public static String getHCFilterQuery() {
		return HCFILTER_QUERY;
	}
	
	/**
	 * Get query statement to get hold code filter list
	 * @return
	 */
	public static String getHCAllFilterQuery() {
		return HC_ALL_FILTER_QUERY;
	}
	
	/**
	 * Get query statement to update hold code filter
	 * @return
	 */
	public static String getHCFilterUpdate() {
		return HCFILTER_UPDATE;
	}
	
	/**
	 * Get query statement to insert hold code filter
	 * @return
	 */
	public static String getHCFilterInsert() {
		return HCFILTER_INSERT;
	}
	
	/**
	 * Get query statement to delete hold code filter
	 * @return
	 */
	public static String getHCFilterDelete() {
		return HCFILTER_DELETE;
	}
	
	/**
	 * Get query statement to get fxFactor list
	 * @return
	 */
	public static String getLastOrderOfHCFilter() {
		return HCFILTER_LAST_ORDER;
	}
	
	/**
	 * Get query statement to get fxFactor list
	 * @return
	 */
	public static String getHCFilterReOder() {
		return HCFILTER_REORDER;
	}
	
	/**
	 * Get statement to set last position
	 * @return
	 */
	public static String getHCFilterSetLastPos() {
		return HCFILTER_SET_LAST_POS;
	}
	
	/**
	 * Get query statement to get fxFactor list
	 * @return
	 */
	public static String getFXFactorQuery() {
		return FX_FACTOR_SELECT;
	}

	/**
	 * Get query statement to update fxFactor
	 * @return
	 */
	public static String getFXFactorUpdate() {
		return FX_FACTOR_UPDATE;
	}

	/**
	 * Get query statement to insert fxFactor 
	 * @return
	 */
	public static String getFXFactorInsert() {
		return FX_FACTOR_INSERT;
	}

	/**
	 * Get query statement for retrieving location list
	 * @return
	 */
	public static String getFshRcpLocationList() {
		return FSH_RCP_LOCATION_LIST;
	}
	
	/**
	 * Get query statement for retrieving stage list
	 * @return
	 */
	public static String getFshRcpStageList() {
		return FSH_RCP_STAGE_LIST;
	}
	
	/**
	 * Get query statement for retrieving eqptype list
	 * @return
	 */
	public static String getFshRcpEqpTypeList() {
		return FSH_RCP_EQPTYPE_LIST;
	}

	/**
	 * Get query released holds statement
	 * @return
	 */
	public static String getReleasedHoldQuery() {
		return RELEASED_HOLDS_SELECT;
	}
	
	/**
	 * Get update released holds statement 
	 * @return
	 */
	public static String getReleasedHoldUpdate() {
		return RELEASED_HOLDS_UPDATE;
	}
	
	/**
	 * Get query statement for retrieving chart factors for displaying in chart
	 * @return
	 */
	public static String getFactor4Chart()
	{
		return FSH_RCP_FACTOR_4_CHART;
	}
	
	/**
	 * Get query statement for retrieving released hold chart factors for displaying in chart
	 * @return
	 */
	public static String getRelHldFactorsQuery()
	{
		return REL_HLD_FACTOR_4_CHART;
	}
	
	/**
	 * Get query statement for retrieving skipped finished recipe condition
	 * @return
	 */
	public static String getSkpFshRcp()
	{
		return SKP_FSH_RCP_CON_SEL;
	}
	
	/**
	 * Get query statement for update skipped finished recipe condition
	 * @return
	 */
	public static String getSkpFshRcpUpd()
	{
		return SKP_FSH_RCP_CON_UPD;
	}
	
	/**
	 * Get query statement for insert new skipped finished recipe condition
	 * @return
	 */
	public static String getSkpFshRcpInst()
	{
		return SKP_FSH_RCP_CON_INS;
	}
	
	/**
	 * Get query statement for update skipped column of all finished recipe
	 * @return
	 */
	public static String getFshRcpSkpColUpd()
	{
		return FSH_RCP_UPD_SKIPPED;
	}
	
	/**
	 * Get query statement for retrieving active hold chart factors for displaying in chart
	 * @return
	 */
	public static String getActHldFactorsQuery()
	{
		return ACT_HLD_FACTOR_4_CHART;
	}
	
	/**
	 * Get query statement for update skipped column of all finished recipe
	 * @return
	 */
	public static String getHldDurByMonth()
	{
		return HLD_DUR_BY_MONTH_CHART;
	}
	
	/**
	 *  get query statement to load all columns setting
	 * @return
	 */
	public static String getAllColsSelectQuery()
	{
		return FRZ_COL_SELECT_ALL;
	}
	
	/**
	 *  get query statement to clear setting of scrolling column
	 * @return
	 */
	public static String getFrzColClear()
	{
		return FRZ_COL_CLEAR;
	}
	
	/**
	 *  get query statement to update setting of scrolling column
	 * @return
	 */
	public static String getFrzColUpdate()
	{
		return FRZ_COL_UPDATE;
	}
	
	/**
	 *  get query statement to select duration color setting
	 * @return
	 */
	public static String getDurColSelect()
	{
		return DUR_COL_SEL;
	}
	
	/**
	 *  get  statement to update duration color setting
	 * @return
	 */
	public static String getDurColUpdate()
	{
		return DUR_COL_UPDATE;
	}
	
	/**
	 *  get  statement to selecting FshRcpRecords
	 * @return
	 */
	public static String getFshRcpRecordQuery()
	{
		return FSH_RCP_RECORDS;
	}
	
	/**
	 *  get  statement to count number of FshRcp Records
	 * @return
	 */
	public static String getFshRcpCountingQuery()
	{
		return FSH_RCP_TOTAL_REC;
	}
	
	/**
	 *  get  statement to select password
	 * @return
	 */
	public static String getPasswordQuery()
	{
		return PWD_SELECT;
	}
	
	/**
	 *  get  statement to select link list
	 * @return
	 */
	public static String getLinkListQuery()
	{
		return LINKS_SELECT;
	}
	
	/**
	 *  get  statement to update link 
	 * @return
	 */
	public static String getLinkUpdateQuery()
	{
		return LINKS_UPDATE;
	}
	
	/**
	 *  get  statement to insert link 
	 * @return
	 */
	public static String getLinkInsertQuery()
	{
		return LINKS_INSERT;
	}
	
	/**
	 *  get  statement to update link 
	 * @return
	 */
	public static String getLinkDeleteQuery()
	{
		return LINKS_DELETE;
	}
}
